<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head>
    <title>找回密码</title>
    <div th:replace="~{fragments/head-base}"></div>
</head>
<body class="body sidebar-left-hidden fixedNav_position fixedMenu_left ">
<div class="preloader" style=" position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 100000;
  backface-visibility: hidden;
  background: #ffffff;">
    <div class="preloader_img" style="width: 200px;
  height: 200px;
  position: absolute;
  left: 48%;
  top: 48%;
  background-position: center;
z-index: 999999">
        <img th:src="@{/img/loader.gif}" style=" width: 50px;" alt="loading...">
    </div>
</div>
<!--wrap-->
<div id="wrap">
    <div th:replace="~{fragments/top :: top}"></div>
    <!-- /#top -->
    <div class="wrapper fixedNav_top">
        <div th:replace="~{fragments/left :: left}"></div>
        <!-- /#left -->
        <div id="content" class="bg-container">
            <div class="outer">
                <div class="inner bg-container">
                    <div class="row">
                        <div style="margin: 0 auto">
                            <div class=" m-t-35 signin_wid" style="width: 400px">
                                <!-- <div class="card-header bg-white">
                                     登录
                                 </div>-->
                                <div>
                                    <!-- logo -->
                                    <div class="m-t-30 text-center">
                                        <img src="img/loginLogo.png" style="width: 300px"/>
                                        <h3 class="mt-4">重设密码和两步验证-最后一步!</h3>
                                    </div>
                                    <form class="mt-3">
                                        <fieldset>
                                            <div class="form-group row">
                                                <div class="col-lg-12 user_icon_change2">
                                                    <div class="input-group">
                                                            <span class="input-group-addon">
                                                               <i class="fa fa-lock"></i>
                                                            </span>
                                                        <input type="password" maxlength="30" minlength="6"
                                                               class="form-control "
                                                               id="password" name="password" placeholder="密码，6-30位">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <div class="col-lg-12 user_icon_change2">
                                                    <div class="input-group">
                                                            <span class="input-group-addon">
                                                               <i class="fa fa-lock"></i>
                                                            </span>
                                                        <input type="password" maxlength="30" minlength="6"
                                                               class="form-control "
                                                               id="rePassword" name="rePassword" placeholder="请再输入一遍">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group row ">
                                                <div class="col-lg-8" style="margin: 0 auto">
                                                    <a href="javascript:void(0)" onclick="forgetSubmitProcess()"
                                                       class="btn btn-danger text-white btn-lg glow_button w-100">重置密码</a>
                                                </div>
                                            </div>
                                        </fieldset>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- /.inner -->
    </div>
    <!-- /.outer -->
    <!-- /#content -->
    <!-- Modal -->
    <div class="modal fade" id="search_modal" tabindex="-1" role="dialog" aria-hidden="true">
        <form th:action="@{/problem/problemList}" method="post">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span class="float-right" aria-hidden="true">&times;</span>
                    </button>
                    <div class="input-group search_bar_small">
                        <input type="text" class="form-control" placeholder="题目搜索" name="keyword">
                        <span class="input-group-btn">
                          <button class="btn btn-secondary" type="submit"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <!-- /#content -->
    <!-- # right side -->
</div>
<!-- /#wrap -->
<!-- global scripts-->
<div th:replace="~{fragments/footer :: footer}"></div>
<!--end of global scripts-->
<!--  plugin scripts -->
<script th:src="@{/js/pages/forgetSubmit.js}"></script>
<!--end of plugin scripts-->

<script th:inline="javascript" type="text/javascript">
    /*<![CDATA[*/
    var token = [[${token}]];
    var email = [[${email}]];

    function forgetSubmitProcess() {
        var password = $("#password").val();
        var rePassword = $("#rePassword").val();
        if (!password || !rePassword) {
            $.message({
                message: '输入不能为空',
                type: 'warning'
            });
            return;
        }
        if (rePassword != password) {
            $.message({
                message: '两次密码不相等',
                type: 'warning'
            });
            return;
        }
        if (password.length < 6) {
            $.message({
                message: '密码不能少于６个字符',
                type: 'warning'
            });
            return;
        }
        $.post("user/forgetSubmitProcess", {"password": password, "token": token, "email": email}, function (resp) {
            if (resp.status == 200) {
                $.message({
                    message: '重置成功',
                    type: 'success'
                });
                // location.href = "/user/loginPage";
            } else {
                $.message({
                    message: resp.msg,
                    type: 'error'
                });
            }
        });
    }

    /*]]>*/
</script>
</body>

</html>
